package pogvue.gui.menus;

import pogvue.gui.AlignViewport;
import pogvue.gui.Controller;

import javax.swing.*;

public abstract class PanelMenu extends JalMenu {
  final JPanel panel;
  final AlignViewport av;
  final Controller    controller;
  
  public PanelMenu(String title, JPanel panel,AlignViewport av,Controller controller) {
    super(title,true);
    this.panel = panel;
    this.av    = av;
    this.controller = controller;

    init();
  }

  public Object getPanelParent() {
    return panel;
  }

  public JMenuItem add(JMenuItem item) {
    return super.add(item);
  }


  protected abstract void init();

  public void setMnemonic(char c) {
    System.out.println("setMnemonic not implemented");
  }

/**
 * Factory method for adding menu items created from actions.
 */
  public JMenuItem add(JalAction action) {
 
    if (av != null && av.getCommandLog() != null) {
      //action.addListener(av.getCommandLog());
      av.getCommandLog().add(action);
    }
    return super.add(action);
  }
}
